<!DOCTYPE html>
<html>
<head>
	<title>prop data</title>
	<meta charset="UTF-8">
	<script src="./vue.js"></script>
</head>
<body>
	<div id="app">
		 <counter :count="2" @change="handleChange"></counter>
		 <counter :count="3" @change="handleChange"></counter>
		 <div>{{total}}</div>
	</div>

	<script>
		var counter = {
			template: `<div @click="handleClick">{{number}}</div>`,
			props: ['count'],
			data: function () {
				return {
					number: this.count
				}
			},
			methods: {
				handleClick: function () {
					this.number++
					this.$emit('change', 1)
				}
			}
		}

		var app = new Vue({
			el: '#app',
			data: {
				total: 5,
			},
			methods: {
				handleChange: function (num) {
					this.total += num
				}
			},
			components: {
				counter: counter
			}
		})
	</script>

</body>
</html>